package cn.edu.huanu.servletlearn;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author hb
 * @date 2025-09-28 15:14:10
 */
@WebServlet("*.do")
public class ResponseServlet extends HttpServlet {

    @Override
    protected void service(HttpServletRequest requset, HttpServletResponse response) throws ServletException, IOException {
      //设置相应数据包中的响应参数，告知浏览器解析的字符编码
      response.setContentType("text/html;charset=utf-8");



        //1. 通过response获得输出流
        PrintWriter out = response.getWriter();
        //向输出流中写入数据
        out.println("<h1>Hello Response</h1>");
        out.println("<h1>response对象是响应数据包。</h1>");
    }
}
